package com.huawei.hms.common.internal;

import com.huawei.hms.api.Api;
import com.huawei.hms.api.Api.ApiOptions;

public class ConnectionManagerKey<TOption extends ApiOptions> {
    private final Api<TOption> a;
    private final TOption b;
    private final boolean c = true;
    private final int d;

    private ConnectionManagerKey(Api<TOption> api, TOption tOption) {
        this.a = api;
        this.b = tOption;
        this.d = Objects.hashCode(this.a, this.b);
    }

    private ConnectionManagerKey(Api<TOption> api) {
        this.a = api;
        this.b = null;
        this.d = System.identityHashCode(this);
    }

    public static <TOption extends ApiOptions> ConnectionManagerKey<TOption> createConnectionManagerKey(Api<TOption> api, TOption tOption) {
        return new ConnectionManagerKey(api, tOption);
    }

    public static <TOption extends ApiOptions> ConnectionManagerKey<TOption> createConnectionManagerKey(Api<TOption> api) {
        return new ConnectionManagerKey(api);
    }

    public final int hashCode() {
        return this.d;
    }

    public final boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof ConnectionManagerKey)) {
            return false;
        }
        ConnectionManagerKey connectionManagerKey = (ConnectionManagerKey) obj;
        if (this.c == connectionManagerKey.c && Objects.equal(this.a, connectionManagerKey.a) && Objects.equal(this.b, connectionManagerKey.b)) {
            return true;
        }
        return false;
    }
}
